1. Field of the Invention
The present invention relates generally to a method and an apparatus for an inter-frame predictive coding of moving images, and more particularly to a method and an apparatus for efficiently encoding where the coding method changes in accordance with inter-frame prediction errors derived from a group of frames before encoding those frames.
2. Description of the Related Art
For designing a coding system for moving images, it is desirable to reduce amount of codes generated in the coding system. For this purpose, an interframe predictive coding is widely used in the coding systems. In these systems, image data of a current frame are predicted from that of a reference frame, and differences between them are encoded. The differences are generally called prediction errors. When the image data of the current frame are exactly predicted, the amount of codes are effectively suppressed. Therefore, it is important to select a suitable reference frame from frames being adjacent to the current frame. Applying motion compensation to prediction procedure is effective for reducing the amount of codes. In this case, motion vectors obtained from positional differences between the image data of the current frame and that of the reference frame, are used for compensating the prediction errors.
In above mentioned operation, the image data are divided into many blocks composed of a predetermined number of pixels (for example, 8.times.8 pixels) and are processed block by block. Thereafter, the prediction errors are discrete cosine transformed, quantized, and encoded into a variable length code.
FIG. 1 shows a series of frames for illustrating how to predict a current frame in an inter-frame predictive coding.
As shown in FIG. 1, an X-frame is not predicted with any frame and is encoded independently. In this case, the amount of codes Ci obtained by actually encoding the I-frame is quite large.
A P-frame is predicted with a preceding frame, and prediction errors in the present frame are calculated. The prediction errors in the present frame are defined as differences between image data of the present frame predicted and that of the present frame actually inputted. Thereafter, the prediction errors are encoded. In this case, the amount of codes Cp obtained by encoding the prediction errors are smaller than the amount of codes obtained by encoding the present frame independently.
A B-frame in the drawing predicted with a preceding P-frame or I-frame. First prediction errors between a current B-frame and a preceding P-frame or I-frame and second prediction errors between a current B-frame and a succeeding P-frame or I-frame are compared, and then, lesser ones are selected by the block from them and are encoded. As a result of this prediction errors selection, the amount of codes of B-frame (Cb) is more reduced.
A current B-frame is generally predicted with both a preceding P-frame or I-frame and a succeeding P-frame or I-frame of which the frames are respectively nearest to the current B-frame. Also, the amount of codes Cp relating to the P-frame, the amount of codes Cb relating to the B-frame, and the amount of codes Ci relating to the I-frame generally satisfy an relationship Ci&gt;Cp&gt;Cb.
Therefore, in cases where a series of frames is encoded, a plurality of B-frames and a plurality of P-frames are set between a pair of I-frames to reduce the total amount of codes Ct obtained by summing them.
In addition, an adaptive inter-frame prediction method in which the number of P-frames or B-frames positioned between the I-frames is adjusted in connection with the sum of the prediction errors in those P-frames or/and B-frames calculated before encoding has been proposed in U.S. Pat. No. 5,105,271.